package com.cy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class NacosConfigApplication {
    public static void main(String[] args) {
        SpringApplication.run(NacosConfigApplication.class,args);
    }
    private static final Logger log=
            LoggerFactory.getLogger(NacosConfigApplication.class);
    @RefreshScope //支持配置动态刷新
    @RestController
    @RequestMapping("/config/")
    public class NacosConfigController {
        @Value("${logging.level.com.cy:info}")//:info  取不到就取默认值info
        private String logLevel;

        @GetMapping("doGetLogLevel")
        public String doGetLogLevel() {
            log.debug("debug info");
            log.error("error info");
            return "Log level is "+logLevel;
        }
        @Value("${server.tomcat.threads.max:128}")
        private Integer maxThread;

        @GetMapping("doGetMaxThread")
        public Integer doGetMaxThread(){
            return maxThread;
        }
        @Value("${page.pageSize:10}")
        private Integer pageSize;

        @GetMapping("doGetPageSize")
        public Integer doGetPageSize(){
            return pageSize;
        }

    }
}
